<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>nginx的rewrite配置 | 西瓜蓬蓬的静谧庭院</title><meta name="keywords" content="运维配置,nginx,rewrite,last,break,redirect,permanent"><meta name="author" content="xiguapengpeng"><meta name="copyright" content="xiguapengpeng"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="nginx的rewrite配置指令语法1rewrite regex replacement [flag];  例子，匹配成功后跳转到百度，执行永久301跳转 1rewrite ^&#x2F;(.*) http:&#x2F;&#x2F;www.baidu.com&#x2F;$1 permanent;  应用位置server、location、if flag参数   参数 描述    last 本条规则匹配完成后继续向下匹配新的locati">
<meta property="og:type" content="article">
<meta property="og:title" content="nginx的rewrite配置">
<meta property="og:url" content="https://xiguapengpeng.gitee.io/posts/4c21c9f0/index.html">
<meta property="og:site_name" content="西瓜蓬蓬的静谧庭院">
<meta property="og:description" content="nginx的rewrite配置指令语法1rewrite regex replacement [flag];  例子，匹配成功后跳转到百度，执行永久301跳转 1rewrite ^&#x2F;(.*) http:&#x2F;&#x2F;www.baidu.com&#x2F;$1 permanent;  应用位置server、location、if flag参数   参数 描述    last 本条规则匹配完成后继续向下匹配新的locati">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220302192352.png">
<meta property="article:published_time" content="2022-03-02T11:42:43.141Z">
<meta property="article:modified_time" content="2022-03-26T06:53:36.493Z">
<meta property="article:author" content="xiguapengpeng">
<meta property="article:tag" content="nginx">
<meta property="article:tag" content="rewrite">
<meta property="article:tag" content="last">
<meta property="article:tag" content="break">
<meta property="article:tag" content="redirect">
<meta property="article:tag" content="permanent">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220302192352.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://xiguapengpeng.gitee.io/posts/4c21c9f0/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="google-site-verification" content="CMfiiaCCwQ90-u9hmlL-7VUq-v_zt9rhyg1Ke1A7ia4"/><meta name="baidu-site-verification" content="code-Wsugu6NsqF"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?0b83b38ff142c9faea5f5987d7c6f3f0";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'nginx的rewrite配置',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-03-26 14:53:36'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.0.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://gitee.com/xiguapengpeng/imgtu/raw/master/blog/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">34</div></a></div><div class="data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">122</div></a></div><div class="data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-compass"></i><span> 导航</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 豆瓣</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li><li><a class="site-page child" href="/game/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220302192352.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">西瓜蓬蓬的静谧庭院</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-compass"></i><span> 导航</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 豆瓣</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li><li><a class="site-page child" href="/game/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">nginx的rewrite配置</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-02T11:42:43.141Z" title="发表于 2022-03-02 19:42:43">2022-03-02</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-26T06:53:36.493Z" title="更新于 2022-03-26 14:53:36">2022-03-26</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/nginx/">nginx</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">393</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>1分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="nginx的rewrite配置"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="nginx的rewrite配置"><a href="#nginx的rewrite配置" class="headerlink" title="nginx的rewrite配置"></a>nginx的rewrite配置</h1><h2 id="指令语法"><a href="#指令语法" class="headerlink" title="指令语法"></a>指令语法</h2><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">rewrite</span> regex replacement [flag];</span><br></pre></td></tr></table></figure>

<p>例子，匹配成功后跳转到百度，执行永久301跳转</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">rewrite</span><span class="regexp"> ^/(.*)</span> http://www.baidu.com/<span class="variable">$1</span> <span class="literal">permanent</span>;</span><br></pre></td></tr></table></figure>

<h2 id="应用位置"><a href="#应用位置" class="headerlink" title="应用位置"></a>应用位置</h2><p><code>server</code>、<code>location</code>、<code>if</code></p>
<h2 id="flag参数"><a href="#flag参数" class="headerlink" title="flag参数"></a>flag参数</h2><table>
<thead>
<tr>
<th align="center">参数</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">last</td>
<td align="center">本条规则匹配完成后继续向下匹配新的location URI规则</td>
</tr>
<tr>
<td align="center">break</td>
<td align="center">本条规则匹配完成后终止，不在匹配任何规则</td>
</tr>
<tr>
<td align="center">redirect</td>
<td align="center">返回302临时重定向</td>
</tr>
<tr>
<td align="center">permanent</td>
<td align="center">返回301永久重定向</td>
</tr>
</tbody></table>
<p><code>last</code>和<code>break</code>用来实现URL重写，浏览器地址栏的URL地址不变，但在服务器访问的程序及路径发生了变化。</p>
<p><code>redirect</code>和<code>permanent</code>用来实现URL跳转，浏览器地址会显示跳转后的URL地址。</p>
<p><code>last</code>和<code>break</code>标记的实现功能类似，但二者之间有细微的差别，使用<code>alias</code>指令时必须用last标记，使用<code>proxy_pass</code>指令时要使用break标记。<code>last</code>标记在本条rewrite规则执行完毕后，会对其所在的server{}标签重新发起请求，而<code>break</code>标记则会在本条规则匹配完成后，终止匹配，不再匹配后面的规则。</p>
<h2 id="常用正则表达式"><a href="#常用正则表达式" class="headerlink" title="常用正则表达式"></a>常用正则表达式</h2><table>
<thead>
<tr>
<th align="center">字符</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">\</td>
<td align="center">将后面接着的字符标记为一个特殊字符或者一个原义字符或一个向后引用</td>
</tr>
<tr>
<td align="center">^</td>
<td align="center">匹配输入字符串的起始位置</td>
</tr>
<tr>
<td align="center">$</td>
<td align="center">匹配输入字符串的结束位置</td>
</tr>
<tr>
<td align="center">*</td>
<td align="center">匹配前面的字符零次或者多次</td>
</tr>
<tr>
<td align="center">+</td>
<td align="center">匹配前面字符串一次或者多次</td>
</tr>
<tr>
<td align="center">?</td>
<td align="center">匹配前面字符串的零次或者一次</td>
</tr>
<tr>
<td align="center">.</td>
<td align="center">匹配除”\n”之外的所有单个字符</td>
</tr>
</tbody></table>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">xiguapengpeng</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://xiguapengpeng.gitee.io/posts/4c21c9f0/">https://xiguapengpeng.gitee.io/posts/4c21c9f0/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://xiguapengpeng.gitee.io" target="_blank">西瓜蓬蓬的静谧庭院</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/nginx/">nginx</a><a class="post-meta__tags" href="/tags/rewrite/">rewrite</a><a class="post-meta__tags" href="/tags/last/">last</a><a class="post-meta__tags" href="/tags/break/">break</a><a class="post-meta__tags" href="/tags/redirect/">redirect</a><a class="post-meta__tags" href="/tags/permanent/">permanent</a></div><div class="post_share"><div class="social-share" data-image="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220302192352.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://gitee.com/xiguapengpeng/imgtu/raw/master/blog/wx_reward.jpg" target="_blank"><img class="post-qr-code-img" src="https://gitee.com/xiguapengpeng/imgtu/raw/master/blog/wx_reward.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/a0d979e3/"><img class="prev-cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220326171119.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">CommonJS模块与ES6模块的区别</div></div></a></div><div class="next-post pull-right"><a href="/posts/75a3de61/"><img class="next-cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220302194109.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">nginx的全局变量</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/cf94e843/" title="nginx中location与proxy_pass的斜杠问题"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220226102216.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-02-26</div><div class="title">nginx中location与proxy_pass的斜杠问题</div></div></a></div><div><a href="/posts/fcbba1fd/" title="nginx的location匹配规则"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220226101852.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-02-26</div><div class="title">nginx的location匹配规则</div></div></a></div><div><a href="/posts/d1432f15/" title="nginx的server匹配规则"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220226102041.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-02-26</div><div class="title">nginx的server匹配规则</div></div></a></div><div><a href="/posts/75a3de61/" title="nginx的全局变量"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220302194109.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-03-02</div><div class="title">nginx的全局变量</div></div></a></div><div><a href="/posts/da432f73/" title="OpenSSL生成证书"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230114172959.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-01-14</div><div class="title">OpenSSL生成证书</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://gitee.com/xiguapengpeng/imgtu/raw/master/blog/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">xiguapengpeng</div><div class="author-info__description">分享知识、勤做笔记</div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">34</div></a></div><div class="card-info-data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">122</div></a></div><div class="card-info-data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xiguapengpeng"><i class="fab fa-heart"></i><span>个人仓库</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">若时光逝却，就珍存过往</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#nginx%E7%9A%84rewrite%E9%85%8D%E7%BD%AE"><span class="toc-number">1.</span> <span class="toc-text">nginx的rewrite配置</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8C%87%E4%BB%A4%E8%AF%AD%E6%B3%95"><span class="toc-number">1.1.</span> <span class="toc-text">指令语法</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BA%94%E7%94%A8%E4%BD%8D%E7%BD%AE"><span class="toc-number">1.2.</span> <span class="toc-text">应用位置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#flag%E5%8F%82%E6%95%B0"><span class="toc-number">1.3.</span> <span class="toc-text">flag参数</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F"><span class="toc-number">1.4.</span> <span class="toc-text">常用正则表达式</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/bd6c95d5/" title="Windows10安装java环境"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230131095714.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Windows10安装java环境"/></a><div class="content"><a class="title" href="/posts/bd6c95d5/" title="Windows10安装java环境">Windows10安装java环境</a><time datetime="2023-01-31T01:59:34.432Z" title="发表于 2023-01-31 09:59:34">2023-01-31</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/fdc8614/" title="Java8到Java17之间的主要特性描述"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230130095755.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Java8到Java17之间的主要特性描述"/></a><div class="content"><a class="title" href="/posts/fdc8614/" title="Java8到Java17之间的主要特性描述">Java8到Java17之间的主要特性描述</a><time datetime="2023-01-30T01:59:04.252Z" title="发表于 2023-01-30 09:59:04">2023-01-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/9542a1f7/" title="CentOS7安装OpenSSL环境"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230114172144.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="CentOS7安装OpenSSL环境"/></a><div class="content"><a class="title" href="/posts/9542a1f7/" title="CentOS7安装OpenSSL环境">CentOS7安装OpenSSL环境</a><time datetime="2023-01-14T09:34:08.209Z" title="发表于 2023-01-14 17:34:08">2023-01-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/da432f73/" title="OpenSSL生成证书"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230114172959.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="OpenSSL生成证书"/></a><div class="content"><a class="title" href="/posts/da432f73/" title="OpenSSL生成证书">OpenSSL生成证书</a><time datetime="2023-01-14T09:33:46.203Z" title="发表于 2023-01-14 17:33:46">2023-01-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/e0523c/" title="CentOS7安装cmake工具"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20221217113021.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="CentOS7安装cmake工具"/></a><div class="content"><a class="title" href="/posts/e0523c/" title="CentOS7安装cmake工具">CentOS7安装cmake工具</a><time datetime="2022-12-17T03:39:03.528Z" title="发表于 2022-12-17 11:39:03">2022-12-17</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220302192352.png')"><div id="footer-wrap"><div class="copyright">&copy;2022 - 2023 By xiguapengpeng</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">醉后不知天在水，满船清梦压星河。</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"></div><div class="aplayer no-destroy" data-id="60198" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="true"></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = ["title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"]

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
  window.scrollCollect && window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/hijiki.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":false},"log":false});</script></body></html>